<html>
<head><meta charset="utf-8"><title>Safe code faster than unsafe?! · wg-secure-code · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/index.html">wg-secure-code</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Safe.20code.20faster.20than.20unsafe.3F!.html">Safe code faster than unsafe?!</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="168888281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Safe%20code%20faster%20than%20unsafe%3F%21/near/168888281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Safe.20code.20faster.20than.20unsafe.3F!.html#168888281">(Jun 24 2019 at 21:53)</a>:</h4>
<p>I've added zero-initialization to growing a Vec and that made the entire decoding process 5% <strong>faster!</strong> I know <code>vec![len; 0];</code> actually requests zeroed memory from the OS, but in here extending the vector with zeroes is supposed to be strictly slower than simply writing to a slice of uninitialized memory! What kind of sorcery is this?! <a href="https://github.com/sile/libflate/pull/34/files" target="_blank" title="https://github.com/sile/libflate/pull/34/files">https://github.com/sile/libflate/pull/34/files</a></p>



<a name="168888392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Safe%20code%20faster%20than%20unsafe%3F%21/near/168888392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Safe.20code.20faster.20than.20unsafe.3F!.html#168888392">(Jun 24 2019 at 21:54)</a>:</h4>
<p>Tests still pass, I've checked</p>



<a name="169411121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Safe%20code%20faster%20than%20unsafe%3F%21/near/169411121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Safe.20code.20faster.20than.20unsafe.3F!.html#169411121">(Jul 01 2019 at 16:51)</a>:</h4>
<p>hahaha, nice</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>